package kr.hkit.androidcomplete01.ch07;

import kr.hkit.androidcomplete01.R;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.View;

public class DrawBitmap extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(new MyView(this));
	}
	
	class MyView extends View {
		
		private Paint paint;
		
		public MyView(Context context) { //우린 하나만 해여
			super(context);
			paint = new Paint(Paint.ANTI_ALIAS_FLAG); //안티엘리어싱 기능있음
		}
		

		@Override
		protected void onDraw(Canvas canvas) {
			super.onDraw(canvas);
			
			canvas.drawColor(Color.LTGRAY);
			
			Resources res = getResources();
			BitmapDrawable bd = (BitmapDrawable) res.getDrawable(R.drawable.ha);
			Bitmap bit = bd.getBitmap();
			
			canvas.drawBitmap(bit, 10, 10, null); //전체 다 그리기
			canvas.drawBitmap(bit, null, new Rect(450, 10, 520, 85), null);
			// 원본을 저 영역에 그리기
			canvas.drawBitmap(bit, new Rect(30, 30, 70, 80), new Rect(550, 10, 550+80, 10+100), null);
			// 얼굴사이즈만 저 영역에 그리기 
			
		}
	}
}
